#include<stdio.h>
#include<string.h>
#include<malloc.h>


void BubbleSort(char (*arr)[10],int len)  //降维，数组指针
{
  int i = 0;
  int flag = 0;
  for(;i<len;i++)
  {
    int j = 0;
    for(;j<len-i-1;j++)
    {
      if(strcmp(arr[j],arr[j+1])>0)
      {
        char *tmp = (char *)malloc(sizeof(arr[j]));
        strcpy(tmp,arr[j]);     //字符串之间交换要用strcpy
        strcpy(arr[j],arr[j+1]);
        strcpy(arr[j+1],tmp);
        flag = 1;
      }
    }
    if(flag == 0)
    {
      break;
    }
  }
}

int main()
{
  char arr[][10] = {"aabceci","a","aacdjsd","adkjj","zz","gcdf","aabceci","aa"};
  int len = sizeof(arr)/sizeof(arr[0]);  //求二维数组行数
  BubbleSort(arr,len);
  int i = 0;
  for(i = 0;i<len;i++)
  {
    printf("%s  ",arr[i]);
  }
  printf("\n");
  return 0;
}
